/**
 * Copyright (c) 2014, 2022 itemis AG (http://www.itemis.eu) and others.
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0.
 * 
 * SPDX-License-Identifier: EPL-2.0
 */
package org.eclipse.xtend.core.tests.compiler;

import org.eclipse.xtend2.lib.StringConcatenation;
import org.junit.Test;

/**
 * @author Jan Koehnlein - Initial contribution and API
 */
@SuppressWarnings("all")
public class AnonymousClassCompilerTest extends AbstractXtendCompilerTest {
  @Test
  public void testPlain() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("new Runnable() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override run() {}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public Runnable m() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return new Runnable() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testExtensions_01() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Test {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("extension Util");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def getRunnable() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("new Runnable {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override run() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("sayHello");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("static class Util {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("def sayHello() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("\'Hello\'");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Extension;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Test {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public static class Util {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("public String sayHello() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("return \"Hello\";");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("@Extension");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("private Test.Util _util;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public Runnable getRunnable() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return new Runnable() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("Test.this._util.sayHello();");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testExtensions_02() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Test {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def getRunnable() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val extension Util u = null");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("new Runnable {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override run() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("sayHello");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("static class Util {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("def sayHello() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("\'Hello\'");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Extension;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Test {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public static class Util {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("public String sayHello() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("return \"Hello\";");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public Runnable getRunnable() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("Runnable _xblockexpression = null;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("{");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("@Extension");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("final Test.Util u = null;");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("_xblockexpression = new Runnable() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("u.sayHello();");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return _xblockexpression;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testExtensions_03() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Test {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def getRunnable() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val Util it = null");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("new Runnable {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override run() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("it.sayHello");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("def void sayHello(Util u) {}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("static class Util {}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Test {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public static class Util {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public Runnable getRunnable() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("abstract class __Test_1 implements Runnable {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public abstract void sayHello(final Test.Util u);");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("__Test_1 _xblockexpression = null;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("{");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("final Test.Util it = null;");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("_xblockexpression = new __Test_1() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("this.sayHello(it);");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("public void sayHello(final Test.Util u) {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return _xblockexpression;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testExtensions_04() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Test {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("extension Util = null");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def getRunnable() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val String it = null");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("new Runnable {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override run() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("sayHello");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("static class Util {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("def void sayHello(String s) {}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Extension;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Test {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public static class Util {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("public void sayHello(final String s) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("@Extension");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("private Test.Util _util = null;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public Runnable getRunnable() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("Runnable _xblockexpression = null;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("{");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("final String it = null;");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("_xblockexpression = new Runnable() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("Test.this._util.sayHello(it);");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return _xblockexpression;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testExtensions_05() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import static extension Util.*");
    _builder.newLine();
    _builder.append("class Test {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def getRunnable() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val String it = null");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("new Runnable {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override run() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("sayHello");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class Util {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("static def void sayHello(String s) {}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Test {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public Runnable getRunnable() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("Runnable _xblockexpression = null;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("{");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("final String it = null;");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("_xblockexpression = new Runnable() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("Util.sayHello(it);");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return _xblockexpression;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testExtensions_06() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import static extension Util.*");
    _builder.newLine();
    _builder.append("class Test {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def getRunnable() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val String it = null");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("new Runnable {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override run() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("sayHello");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class Util {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("static def void sayHello(Runnable r) {}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Test {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public Runnable getRunnable() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("Runnable _xblockexpression = null;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("{");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("final String it = null;");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("_xblockexpression = new Runnable() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("Util.sayHello(this);");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return _xblockexpression;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testExtensions_07() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import static extension Util.*");
    _builder.newLine();
    _builder.append("class Test {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def getRunnable() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val String it = null");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("new Runnable {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override run() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("sayHello");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class Util {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("static def void sayHello(Test t) {}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Test {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public Runnable getRunnable() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("Runnable _xblockexpression = null;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("{");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("final String it = null;");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("_xblockexpression = new Runnable() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("Util.sayHello(Test.this);");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return _xblockexpression;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testExtensions_08() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Test {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("extension Util u");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def getRunnable() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("new Runnable {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override run() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("sayHello");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("static class Util {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("def void sayHello(Runnable r) {}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Extension;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Test {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public static class Util {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("public void sayHello(final Runnable r) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("@Extension");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("private Test.Util u;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public Runnable getRunnable() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return new Runnable() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("Test.this.u.sayHello(this);");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testExtensions_09() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Test {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("extension Util u");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def getRunnable() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("new Runnable {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override run() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("Test.this.sayHello");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("static class Util {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("def void sayHello(Runnable r) {}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("def void sayHello(Test t) {}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Extension;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Test {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public static class Util {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("public void sayHello(final Runnable r) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("public void sayHello(final Test t) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("@Extension");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("private Test.Util u;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public Runnable getRunnable() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return new Runnable() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("Test.this.u.sayHello(Test.this);");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testExtensions_10() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Test {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("extension Util u");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def getRunnable() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("new Runnable {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override run() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("sayHello");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("static class Util {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("def void sayHello(Test t) {}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Extension;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Test {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public static class Util {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("public void sayHello(final Test t) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("@Extension");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("private Test.Util u;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public Runnable getRunnable() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return new Runnable() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("Test.this.u.sayHello(Test.this);");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testForwardFieldReference() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Bar {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("val r = new Runnable() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("override run() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("println(x)");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("public val x = 1");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.InputOutput;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Bar {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("private final Runnable r = new Runnable() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("InputOutput.<Integer>println(Integer.valueOf(Bar.this.x));");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public final int x = 1;");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testTypeUsed() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val d = new D() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("/** comment */");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("final def op1() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("public def op2() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("private def op3() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override toString() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("\'\'");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("d.op1");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("d");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("static class D {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public static class D {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public C.D m() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("abstract class __C_1 extends C.D {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("/**");
    _builder_1.newLine();
    _builder_1.append("       ");
    _builder_1.append("* comment");
    _builder_1.newLine();
    _builder_1.append("       ");
    _builder_1.append("*/");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public abstract Object op1();");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public abstract Object op2();");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("abstract Object op3();");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("__C_1 _xblockexpression = null;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("{");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("final __C_1 d = new __C_1() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("/**");
    _builder_1.newLine();
    _builder_1.append("         ");
    _builder_1.append("* comment");
    _builder_1.newLine();
    _builder_1.append("         ");
    _builder_1.append("*/");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("public final Object op1() {");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("return null;");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("public Object op2() {");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("return null;");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("Object op3() {");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("return null;");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("public String toString() {");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("return \"\";");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("d.op1();");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("_xblockexpression = d;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return _xblockexpression;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testTypeUsedAndConstructor() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val d = new D(true, 1) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("final def op1() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("d.op1");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("d");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("static class D {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("new(boolean b, int i) {}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public static class D {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("public D(final boolean b, final int i) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public C.D m() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("abstract class __C_1 extends C.D {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("__C_1(final boolean b, final int i) {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("super(b, i);");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public abstract Object op1();");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("__C_1 _xblockexpression = null;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("{");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("final __C_1 d = new __C_1(true, 1) {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("public final Object op1() {");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("return null;");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("d.op1();");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("_xblockexpression = d;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return _xblockexpression;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testTypeUsed_02() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val i = {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("val i2 = new I() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("public def op() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("i2");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("i.op");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("interface I {}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public interface I {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public Object m() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("abstract class __C_1 implements C.I {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public abstract Object op();");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("Object _xblockexpression = null;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("{");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("__C_1 _xblockexpression_1 = null;");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("{");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("final __C_1 i2 = new __C_1() {");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("public Object op() {");
    _builder_1.newLine();
    _builder_1.append("            ");
    _builder_1.append("return null;");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("_xblockexpression_1 = i2;");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("final __C_1 i = _xblockexpression_1;");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("_xblockexpression = i.op();");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return _xblockexpression;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testTwoClasses() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def void m() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("new Runnable() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override run() {}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("new Runnable() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override run() {}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public void m() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("new Runnable() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("new Runnable() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testTwoClassesWithMembers() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def void m() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("new Runnable() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override run() {}");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("def void m() {}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("new Runnable() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override run() {}");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("def void m() {}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public void m() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("abstract class __C_1 implements Runnable {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public abstract void m();");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("abstract class __C_2 implements Runnable {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public abstract void m();");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("new __C_1() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void m() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("new __C_2() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void m() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testConstructor() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("new D(true) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("static class D {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("new(boolean b) {}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("new(int i) {}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public static class D {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("public D(final boolean b) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("public D(final int i) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public C.D m() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return new C.D(true) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testConstructorAdditionalMember() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("new D(true) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("def void n() {}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("static class D {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("new(boolean b) {}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("new(int i) {}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public static class D {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("public D(final boolean b) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("public D(final int i) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public C.D m() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("abstract class __C_1 extends C.D {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("__C_1(final boolean b) {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("super(b);");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public abstract void n();");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return new __C_1(true) {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void n() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testNestedLocalClass_01() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("return newArrayList(new Runnable() { override run() {} })");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import java.util.ArrayList;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.CollectionLiterals;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public ArrayList<? extends Runnable> m() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return CollectionLiterals.<Runnable>newArrayList(new Runnable() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("});");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testNestedLocalClass_02() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def Iterable<Runnable> m() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("return newArrayList(new Runnable() { override run() {} })");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.CollectionLiterals;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public Iterable<Runnable> m() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return CollectionLiterals.<Runnable>newArrayList(new Runnable() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("});");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testNestedLocalClass_03() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("return newArrayList(");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("new Runnable() { override run() {} def void m() {} }");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append(")");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import java.util.ArrayList;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.CollectionLiterals;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public ArrayList<? extends Runnable> m() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("abstract class __C_1 implements Runnable {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public abstract void m();");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("__C_1 ___C_1 = new __C_1() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void m() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return CollectionLiterals.<__C_1>newArrayList(___C_1);");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testNestedLocalClass_04() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("return newArrayList(");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("new Runnable() { override run() {} def void m() {} },");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("new Runnable() { override run() {} def void m() {} }");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append(")");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import java.util.ArrayList;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.CollectionLiterals;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public ArrayList<Runnable> m() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("abstract class __C_1 implements Runnable {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public abstract void m();");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("abstract class __C_2 implements Runnable {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public abstract void m();");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("__C_1 ___C_1 = new __C_1() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void m() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("__C_2 ___C_2 = new __C_2() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void m() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return CollectionLiterals.<Runnable>newArrayList(___C_1, ___C_2);");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testNestedLocalClass_05() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("return newArrayList(newArrayList(new Runnable() { override run() {} def void m() {} }))");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import java.util.ArrayList;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.CollectionLiterals;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public ArrayList<? extends ArrayList<? extends Runnable>> m() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("abstract class __C_1 implements Runnable {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public abstract void m();");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("__C_1 ___C_1 = new __C_1() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void m() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return CollectionLiterals.<ArrayList<__C_1>>newArrayList(CollectionLiterals.<__C_1>newArrayList(___C_1));");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testCapturedLocalVar_01() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def foo() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val x = \'\'");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val bar = new Runnable() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override run() { x.toString }");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Foo {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public void foo() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final String x = \"\";");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final Runnable bar = new Runnable() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("x.toString();");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testCapturedLocalVar_02() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def foo() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("var x = \'\'");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val bar = new Runnable() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("String x");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override run() { x.toString }");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Foo {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public void foo() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("abstract class __Foo_1 implements Runnable {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("String x;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("String x = \"\";");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final __Foo_1 bar = new __Foo_1() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("this.x.toString();");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testCapturedLocalVar_03() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def foo() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val x = \'\'");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val bar = new Runnable() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("String x");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override run() { x.toString }");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Foo {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public void foo() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("abstract class __Foo_1 implements Runnable {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("String x;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final String x = \"\";");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final __Foo_1 bar = new __Foo_1() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("this.x.toString();");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testCapturedLocalVar_04() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("val x = \'\'");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def foo() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val x = \'\'");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val bar = new Runnable() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("String x");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override run() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("new Object() {");
    _builder.newLine();
    _builder.append("\t\t\t\t\t");
    _builder.append("override toString() {");
    _builder.newLine();
    _builder.append("\t\t\t\t\t\t");
    _builder.append("x");
    _builder.newLine();
    _builder.append("\t\t\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Foo {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("private final String x = \"\";");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public void foo() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("abstract class __Foo_1 implements Runnable {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("final __Foo_1 _this__Foo_1 = this;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("String x;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final String x = \"\";");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final __Foo_1 bar = new __Foo_1() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("new Object() {");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("public String toString() {");
    _builder_1.newLine();
    _builder_1.append("            ");
    _builder_1.append("return _this__Foo_1.x;");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testCapturedLocalVar_05() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("val x = \'\'");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def foo() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val bar = new Runnable() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("String x");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override run() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("val String x = \'\'");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("new Object() {");
    _builder.newLine();
    _builder.append("\t\t\t\t\t");
    _builder.append("override toString() {");
    _builder.newLine();
    _builder.append("\t\t\t\t\t\t");
    _builder.append("x");
    _builder.newLine();
    _builder.append("\t\t\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Foo {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("private final String x = \"\";");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public void foo() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("abstract class __Foo_1 implements Runnable {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("String x;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final __Foo_1 bar = new __Foo_1() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("final String x = \"\";");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("new Object() {");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("public String toString() {");
    _builder_1.newLine();
    _builder_1.append("            ");
    _builder_1.append("return x;");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testCapturedLocalVar_06() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def foo(String x) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val bar = new Runnable() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("String x");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override run() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("x.toString");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Foo {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public void foo(final String x) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("abstract class __Foo_1 implements Runnable {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("String x;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final __Foo_1 bar = new __Foo_1() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("this.x.toString();");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testCapturedLocalVar_07() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def foo() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val bar = new Runnable() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("String x");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override run() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("def void m(String x) {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("x.toString");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Foo {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public void foo() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("abstract class __Foo_1 implements Runnable {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("String x;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public abstract void m(final String x);");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final __Foo_1 bar = new __Foo_1() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void m(final String x) {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("x.toString();");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testCapturedLocalVar_08() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("Object x");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m(String x) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("new Object() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override toString() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("x.substring(1)");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("private Object x;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public Object m(final String x) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return new Object() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public String toString() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("return x.substring(1);");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testCapturedLocalVar_09() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package foo");
    _builder.newLine();
    _builder.append("import org.eclipse.xtext.xbase.lib.Functions.Function0");
    _builder.newLine();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def foo() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("var String name");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("bar(new Function0<String>() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("String name");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override apply() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("name");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("})");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def bar(()=>String f) {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("package foo;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Functions.Function0;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Foo {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public Object foo() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("abstract class __Foo_1 implements Function0<String> {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("String name;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("Object _xblockexpression = null;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("{");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("String name = null;");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("__Foo_1 ___Foo_1 = new __Foo_1() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("public String apply() {");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("return this.name;");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("_xblockexpression = this.bar(___Foo_1);");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return _xblockexpression;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public Object bar(final Function0<? extends String> f) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return null;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testCapturedLocalVar_10() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def foo() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val CharSequence x = new StringBuilder;");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("if (x instanceof Appendable)");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("new Runnable() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("override run() { x.append(\'hello\') }");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Exceptions;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Foo {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public Runnable foo() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("Runnable _xblockexpression = null;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("{");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("final CharSequence x = new StringBuilder();");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("Runnable _xifexpression = null;");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("if ((x instanceof Appendable)) {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("_xifexpression = new Runnable() {");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("            ");
    _builder_1.append("try {");
    _builder_1.newLine();
    _builder_1.append("              ");
    _builder_1.append("((Appendable)x).append(\"hello\");");
    _builder_1.newLine();
    _builder_1.append("            ");
    _builder_1.append("} catch (Throwable _e) {");
    _builder_1.newLine();
    _builder_1.append("              ");
    _builder_1.append("throw Exceptions.sneakyThrow(_e);");
    _builder_1.newLine();
    _builder_1.append("            ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("_xblockexpression = _xifexpression;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return _xblockexpression;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testCapturedLocalVar_11() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def foo(CharSequence x) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("if (x instanceof Appendable)");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("new Runnable() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("override run() { x.append(\'hello\') }");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Exceptions;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Foo {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public Runnable foo(final CharSequence x) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("Runnable _xifexpression = null;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("if ((x instanceof Appendable)) {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("_xifexpression = new Runnable() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("try {");
    _builder_1.newLine();
    _builder_1.append("            ");
    _builder_1.append("((Appendable)x).append(\"hello\");");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("} catch (Throwable _e) {");
    _builder_1.newLine();
    _builder_1.append("            ");
    _builder_1.append("throw Exceptions.sneakyThrow(_e);");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return _xifexpression;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testLocalVar() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def foo() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val bar = new Runnable() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override run() {}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Foo {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public void foo() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final Runnable bar = new Runnable() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testNestedTypeScoping_01() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def newMap() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("return new java.util.AbstractMap<String, String>() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override java.util.Set<Entry<String, String>> entrySet() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("newHashSet");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import java.util.AbstractMap;");
    _builder_1.newLine();
    _builder_1.append("import java.util.Map;");
    _builder_1.newLine();
    _builder_1.append("import java.util.Set;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.CollectionLiterals;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public AbstractMap<String, String> newMap() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return new AbstractMap<String, String>() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public Set<Map.Entry<String, String>> entrySet() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("return CollectionLiterals.<Map.Entry<String, String>>newHashSet();");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testNestedTypeScoping_02() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def newMap() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("return new java.util.AbstractMap<String, String>() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override entrySet() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("<Entry<String, String>>newHashSet");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import java.util.AbstractMap;");
    _builder_1.newLine();
    _builder_1.append("import java.util.Map;");
    _builder_1.newLine();
    _builder_1.append("import java.util.Set;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.CollectionLiterals;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public AbstractMap<String, String> newMap() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return new AbstractMap<String, String>() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public Set<Map.Entry<String, String>> entrySet() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("return CollectionLiterals.<Map.Entry<String, String>>newHashSet();");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testNestedTypeScoping_03() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def newMap() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("return new java.util.AbstractMap<String, String>() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override entrySet() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("Entry.declaredMethods // doesn\'t make much sense");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("#{}");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import java.util.AbstractMap;");
    _builder_1.newLine();
    _builder_1.append("import java.util.Collections;");
    _builder_1.newLine();
    _builder_1.append("import java.util.Map;");
    _builder_1.newLine();
    _builder_1.append("import java.util.Set;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.CollectionLiterals;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public AbstractMap<String, String> newMap() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return new AbstractMap<String, String>() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public Set<Map.Entry<String, String>> entrySet() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("Set<Map.Entry<String, String>> _xblockexpression = null;");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("{");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("Map.Entry.class.getDeclaredMethods();");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("_xblockexpression = Collections.<Map.Entry<String, String>>unmodifiableSet(CollectionLiterals.<Map.Entry<String, String>>newHashSet());");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("return _xblockexpression;");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testThisScoping_01() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def newD() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("return new D {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("def m() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("return this");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class D {}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public D newD() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("abstract class __C_1 extends D {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public abstract __C_1 m();");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return new __C_1() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public __C_1 m() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("return this;");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testThisScoping_02() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def newD() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("return new D {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("def m() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("return toString");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class D {}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public D newD() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("abstract class __C_1 extends D {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public abstract String m();");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return new __C_1() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public String m() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("return this.toString();");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testThisScoping_03() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def newD() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("return new D {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("def m() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("m2");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def void m2() {}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class D {}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public D newD() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("abstract class __C_1 extends D {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public abstract void m();");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return new __C_1() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void m() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("C.this.m2();");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public void m2() {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testThisScoping_04() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def newD() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("return new D {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("def m() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("C.this.m");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def void m() {}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class D {}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public D newD() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("abstract class __C_1 extends D {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public abstract void m();");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return new __C_1() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void m() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("C.this.m();");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public void m() {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testSuperScoping_01() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C extends B {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def myMethod() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("return new D {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override m() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("super.m");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("override m() {}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class B { def void m() {} }");
    _builder.newLine();
    _builder.append("class D extends E {}");
    _builder.newLine();
    _builder.append("class E { def void m() {} }");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C extends B {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public D myMethod() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return new D() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void m() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("super.m();");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public void m() {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testSuperScoping_02() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C extends B {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def myMethod() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("return new D {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override m() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("C.super.m");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("override m() {}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class B { def void m() {} }");
    _builder.newLine();
    _builder.append("class D extends E {}");
    _builder.newLine();
    _builder.append("class E { def void m() {} }");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C extends B {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public D myMethod() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return new D() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void m() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("C.super.m();");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public void m() {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testLocalVar_AdditionalMember() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def foo() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val bar = new Runnable() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override run() {}");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("int baz");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Foo {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public void foo() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("abstract class __Foo_1 implements Runnable {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("int baz;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final __Foo_1 bar = new __Foo_1() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testLocalVar_AdditionalMember_Return() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def foo() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("new Runnable() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override run() {}");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("int baz");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Foo {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public Runnable foo() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("abstract class __Foo_1 implements Runnable {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("int baz;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return new __Foo_1() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testLocalVarInArray_01() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def foo() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val Object[] bar = #[ ");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("new Runnable() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("override run() {}");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("]");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Foo {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public void foo() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final Object[] bar = new Object[] { new Runnable() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("} };");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testLocalVarInArray_02() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def foo() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val bar = #[ ");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("new Runnable() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("override run() {}");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("]");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import java.util.Collections;");
    _builder_1.newLine();
    _builder_1.append("import java.util.List;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.CollectionLiterals;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Foo {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public void foo() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final List<Runnable> bar = Collections.<Runnable>unmodifiableList(CollectionLiterals.<Runnable>newArrayList(new Runnable() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}));");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testField() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("val bar = new Runnable() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("override run() {}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Foo {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("private final Runnable bar = new Runnable() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testField_AdditionalMember_01() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("val bar = new Runnable() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("int baz");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("override run() {}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Functions.Function0;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Foo {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("private final Runnable bar = new Function0<Runnable>() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("public Runnable apply() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("abstract class __Foo_1 implements Runnable {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("int baz;");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("__Foo_1 ___Foo_1 = new __Foo_1() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("return ___Foo_1;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}.apply();");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testField_AdditionalMember_02() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("val secondOuterField = 1");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("val outerField = new Object() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("int localField");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("} => [ localField = secondOuterField ]");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Functions.Function0;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.ObjectExtensions;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("private final int secondOuterField = 1;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("private final Object outerField = new Function0<Object>() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("public Object apply() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("abstract class __C_1 {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("int localField;");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("__C_1 ___C_1 = new __C_1() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("final Procedure1<__C_1> _function = new Procedure1<__C_1>() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("public void apply(final __C_1 it) {");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("it.localField = C.this.secondOuterField;");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("__C_1 _doubleArrow = ObjectExtensions.<__C_1>operator_doubleArrow(___C_1, _function);");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("return _doubleArrow;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}.apply();");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testFieldInitializerUsesCapturedLocal_01() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val s1 = \'\'");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val r = new Runnable() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("val s2 = s1");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override run() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("s2.toString");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("r");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public Runnable m() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("abstract class __C_1 implements Runnable {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("String s2;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("__C_1 _xblockexpression = null;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("{");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("final String s1 = \"\";");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("final __C_1 r = new __C_1() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("{");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("s2 = s1;");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("this.s2.toString();");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("_xblockexpression = r;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return _xblockexpression;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testFieldInitializerUsesCapturedLocal_02() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val s = \'\'");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val r = new Runnable() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("val idx = try {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("s.substring(1).length");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("} catch(Exception e) {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("-1");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override run() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("idx.toString");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("r");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Exceptions;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Functions.Function0;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public Runnable m() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("abstract class __C_1 implements Runnable {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("int idx;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("__C_1 _xblockexpression = null;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("{");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("final String s = \"\";");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("final __C_1 r = new __C_1() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("{");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("idx = new Function0<Integer>() {");
    _builder_1.newLine();
    _builder_1.append("            ");
    _builder_1.append("public Integer apply() {");
    _builder_1.newLine();
    _builder_1.append("              ");
    _builder_1.append("int _xtrycatchfinallyexpression = (int) 0;");
    _builder_1.newLine();
    _builder_1.append("              ");
    _builder_1.append("try {");
    _builder_1.newLine();
    _builder_1.append("                ");
    _builder_1.append("_xtrycatchfinallyexpression = s.substring(1).length();");
    _builder_1.newLine();
    _builder_1.append("              ");
    _builder_1.append("} catch (final Throwable _t) {");
    _builder_1.newLine();
    _builder_1.append("                ");
    _builder_1.append("if (_t instanceof Exception) {");
    _builder_1.newLine();
    _builder_1.append("                  ");
    _builder_1.append("_xtrycatchfinallyexpression = (-1);");
    _builder_1.newLine();
    _builder_1.append("                ");
    _builder_1.append("} else {");
    _builder_1.newLine();
    _builder_1.append("                  ");
    _builder_1.append("throw Exceptions.sneakyThrow(_t);");
    _builder_1.newLine();
    _builder_1.append("                ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("              ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("              ");
    _builder_1.append("return _xtrycatchfinallyexpression;");
    _builder_1.newLine();
    _builder_1.append("            ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("}.apply().intValue();");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("Integer.valueOf(this.idx).toString();");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("_xblockexpression = r;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return _xblockexpression;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testAdditionalMemberAccess_01() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("new Object() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("public int f");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("} => [ f = 1 ]");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.ObjectExtensions;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public Object m() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("abstract class __C_1 {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("int f;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("__C_1 ___C_1 = new __C_1() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final Procedure1<__C_1> _function = new Procedure1<__C_1>() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void apply(final __C_1 it) {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("it.f = 1;");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return ObjectExtensions.<__C_1>operator_doubleArrow(___C_1, _function);");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testGeneric() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def foo() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val bar = new Iterable<String>() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override iterator() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("null");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import java.util.Iterator;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Foo {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public void foo() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final Iterable<String> bar = new Iterable<String>() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public Iterator<String> iterator() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("return null;");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testGeneric1() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo  {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def <T> foo() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val bar = new Iterable<T>() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override iterator() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("null");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import java.util.Iterator;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Foo {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public <T extends Object> void foo() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final Iterable<T> bar = new Iterable<T>() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public Iterator<T> iterator() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("return null;");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testGeneric2() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import java.util.Iterator");
    _builder.newLine();
    _builder.newLine();
    _builder.append("class Foo  {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def <T> foo() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val bar = new Iterable<T>() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override Iterator<T> iterator() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("null");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import java.util.Iterator;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Foo {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public <T extends Object> void foo() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final Iterable<T> bar = new Iterable<T>() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public Iterator<T> iterator() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("return null;");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testGeneric3() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo<T>  {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def <U> foo() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val bar = new Bar<T,U>() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override T bar(U it) {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("null");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("interface Bar<V,W> {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def V bar(W it)");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Foo<T extends Object> {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public <U extends Object> void foo() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final Bar<T, U> bar = new Bar<T, U>() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public T bar(final U it) {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("return null;");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testGeneric4() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo<T>  {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def foo() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val bar = new Bar<T>() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override <U> U bar(T it) {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("null");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("interface Bar<V> {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def <W> W bar(V it)");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Foo<T extends Object> {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public void foo() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final Bar<T> bar = new Bar<T>() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public <U extends Object> U bar(final T it) {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("return null;");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testGeneric5() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("new Object {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("def <T> T m2() {}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public Object m() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("abstract class __C_1 {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public abstract <T extends Object> T m2();");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return new __C_1() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public <T extends Object> T m2() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("return null;");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testGeneric6() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def <K> m() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("new Object {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("def <V> m2() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("new java.util.AbstractMap<K, V> {");
    _builder.newLine();
    _builder.append("\t\t\t\t\t");
    _builder.append("def Entry<K, V> m() {}");
    _builder.newLine();
    _builder.append("\t\t\t\t\t");
    _builder.append("override entrySet() {}");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import java.util.AbstractMap;");
    _builder_1.newLine();
    _builder_1.append("import java.util.Map;");
    _builder_1.newLine();
    _builder_1.append("import java.util.Set;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class C {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public <K extends Object> Object m() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("abstract class __C_1 {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public abstract <V extends Object> AbstractMap<K, V> m2();");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return new __C_1() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public <V extends Object> AbstractMap<K, V> m2() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("abstract class ____C_1 extends AbstractMap<K, V> {");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("public abstract Map.Entry<K, V> m();");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("return new ____C_1() {");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("public Map.Entry<K, V> m() {");
    _builder_1.newLine();
    _builder_1.append("            ");
    _builder_1.append("return null;");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("public Set<Map.Entry<K, V>> entrySet() {");
    _builder_1.newLine();
    _builder_1.append("            ");
    _builder_1.append("return null;");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testGeneric7() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo<T>  {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def <W extends Foo<W>> foo() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val bar = new Bar<W>() {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override bar() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("null");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("interface Bar<V extends Foo<V>> {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("def V bar()");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Foo<T extends Object> {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public interface Bar<V extends Foo<V>> {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("V bar();");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public <W extends Foo<W>> void foo() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final Foo.Bar<W> bar = new Foo.Bar<W>() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public W bar() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("return null;");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testFinalField_01() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def void foo() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val y = 1");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("new Object {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("val x = y");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("def void bar() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("println(x)");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.InputOutput;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Foo {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public void foo() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("abstract class __Foo_1 {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("int x;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public abstract void bar();");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final int y = 1;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("new __Foo_1() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("{");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("x = y;");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void bar() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("InputOutput.<Integer>println(Integer.valueOf(this.x));");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testFinalField_02() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def void foo() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val y = 1");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("new Object {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("static val x = y");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("def void bar() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("println(x)");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.InputOutput;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Foo {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public void foo() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("abstract class __Foo_1 {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("static final int x = 1;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public abstract void bar();");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("final int y = 1;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("new __Foo_1() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void bar() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("InputOutput.<Integer>println(Integer.valueOf(__Foo_1.x));");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testBug462313() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import test.Visibilities");
    _builder.newLine();
    _builder.append("class MyXtendClass {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def void bar() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("new Visibilities {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("override publicMethod() {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("new Thread {");
    _builder.newLine();
    _builder.append("\t\t\t\t\t");
    _builder.append("override run() {");
    _builder.newLine();
    _builder.append("\t\t\t\t\t\t");
    _builder.append("protectedMethod");
    _builder.newLine();
    _builder.append("\t\t\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("super.publicMethod");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}\t");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import test.Visibilities;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class MyXtendClass {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public void bar() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("new Visibilities() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public void publicMethod() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("new Thread() {");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("public void run() {");
    _builder_1.newLine();
    _builder_1.append("            ");
    _builder_1.append("protectedMethod();");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("super.publicMethod();");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testAnnotation() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class InstanceTest {");
    _builder.newLine();
    _builder.newLine();
    _builder.append("    ");
    _builder.append("def doSomething() {");
    _builder.newLine();
    _builder.newLine();
    _builder.append("        ");
    _builder.append("var MyConfiguration config = new MyConfiguration() {");
    _builder.newLine();
    _builder.newLine();
    _builder.append("             ");
    _builder.append("override annotationType() {");
    _builder.newLine();
    _builder.append("                 ");
    _builder.append("null");
    _builder.newLine();
    _builder.append("             ");
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("             ");
    _builder.append("override name() {");
    _builder.newLine();
    _builder.append("                 ");
    _builder.append("null");
    _builder.newLine();
    _builder.append("             ");
    _builder.append("}");
    _builder.newLine();
    _builder.append("        ");
    _builder.append("}");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("annotation MyConfiguration {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("String name = \'osgi\'");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import java.lang.annotation.Annotation;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class InstanceTest {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public void doSomething() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("MyConfiguration config = new MyConfiguration() {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public Class<? extends Annotation> annotationType() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("return null;");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("public String name() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("return null;");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }

  @Test
  public void testXtendIssue1301() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import org.eclipse.emf.ecore.EObject");
    _builder.newLine();
    _builder.append("import org.eclipse.emf.common.notify.impl.AdapterImpl");
    _builder.newLine();
    _builder.append("class Sample {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def getMyAdapter(extension EObject it) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("eAdapters.filter(AdapterImpl).head ?: (new AdapterImpl() => [eAdapters += it])");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import com.google.common.collect.Iterables;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.emf.common.notify.Adapter;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.emf.common.notify.impl.AdapterImpl;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.emf.common.util.EList;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.emf.ecore.EObject;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Extension;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.IterableExtensions;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.ObjectExtensions;");
    _builder_1.newLine();
    _builder_1.append("import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Sample {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public AdapterImpl getMyAdapter(@Extension final EObject it) {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("AdapterImpl _elvis = null;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("AdapterImpl _head = IterableExtensions.<AdapterImpl>head(Iterables.<AdapterImpl>filter(it.eAdapters(), AdapterImpl.class));");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("if (_head != null) {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("_elvis = _head;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("} else {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("AdapterImpl _adapterImpl = new AdapterImpl();");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("final Procedure1<AdapterImpl> _function = new Procedure1<AdapterImpl>() {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("public void apply(final AdapterImpl it_1) {");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("EList<Adapter> _eAdapters = it.eAdapters();");
    _builder_1.newLine();
    _builder_1.append("          ");
    _builder_1.append("_eAdapters.add(it_1);");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("AdapterImpl _doubleArrow = ObjectExtensions.<AdapterImpl>operator_doubleArrow(_adapterImpl, _function);");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("_elvis = _doubleArrow;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("return _elvis;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }
}
